/*
 * Copyright (C) 2025 ameise <ameise.wang@gmail.com> - All Rights Reserved
 *
 * This file is part of e3pool.
 *
 * e3pool is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * e3pool is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with e3pool. If not, see <https://www.gnu.org/licenses/>.
 */

package go_pool

import "golang.org/x/time/rate"

func DefaultOptions() *Options {
	return &Options{
		simCount:  1,
		limiter:   nil,
		isBlock:   true,
		cacheSize: 0,
	}
}

type Options struct {
	simCount  uint32 // 并发数量,0:代表无限并发
	limiter   *rate.Limiter
	isBlock   bool
	cacheSize int
}

func (ts *Options) SetSimCount(simCount uint32) *Options {
	ts.simCount = simCount
	return ts
}

func (ts *Options) SetLimiter(l *rate.Limiter) *Options {
	ts.limiter = l
	return ts
}

func (ts *Options) SetBlock(ok bool) *Options {
	ts.isBlock = ok
	return ts
}

func (ts *Options) SetSize(size int) *Options {
	ts.cacheSize = size
	return ts
}
